#include "process.h"
#include "unistd.h"
#include <string.h>

char arr[101] = {0};
int pos = 0;

void progress_init()
{
  pos = 0;
  memset(arr, ' ', 100);
  printf("process_init ready\n");
}



void progress(float now, float tal)
{
  int rate = now * 100 / tal;
  
  int i = pos;
  for(; i <= rate; i++)
  {
    printf("[%s][%d%%][%.1f / %.1f]\r", arr, i, now, tal);
    arr[i] = '#';

    fflush(stdout);//刷新输出缓存
    usleep(20000);
  }
  pos = i;
}
